from abc import ABC, abstractmethod
from typing import List, Optional, Dict, Any
from dataclasses import dataclass
from datetime import datetime

@dataclass
class DownloadProgress:
    total_size: int
    downloaded_size: int
    speed: float  # bytes/s
    status: str
    started_at: datetime
    
@dataclass
class ContentMetadata:
    platform: str
    content_type: str
    url: str
    publish_time: datetime
    author: str
    likes: Optional[int] = None
    comments: Optional[int] = None
    collections: Optional[int] = None


class BaseDownloader(ABC):
    def __init__(self, config: Dict[str, Any]):
        self.config = config
        self.progress: Optional[DownloadProgress] = None


    @abstractmethod
    async def download_by_url(self, url: str) -> Dict[str, Any]:
        """下载单个内容"""
        pass

    @abstractmethod
    async def download_by_author(self, author_id: str, **filters) -> List[Dict[str, Any]]:
        """下载作者的所有内容"""
        pass

    @abstractmethod
    async def search_and_download(self, keyword: str, **filters) -> List[Dict[str, Any]]:
        """搜索并下载内容"""
        pass